package com.hao1st.producer.biz.mqdemo.controller;

import jakarta.annotation.Resource;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class ProducerController {
    /**
     * 向消息队列发送消息用
     */
    @Resource
    private StreamBridge streamBridge;

    @GetMapping("/index")
    public String index() {
        return "producer的index被访问";
    }

    @GetMapping("/sendMsg")
    public String sendMessage() {

        Map<String, String> person = new HashMap<>();
        person.put("name", "sanjingye");

        streamBridge.send("mq-in-0", person);

        return "消息发送成功";
    }
}
